Skip to main content

6. Error Handling

6.1 Introduction

This middleware function is responsible for handling errors that occur during the processing of license checks. It logs error details, updates the license check status, and sends a response to the client.

6.2 Functionality

  1. Logs the error details to the console for debugging purposes.
  2. Uses the addLicenceCheckHistory function to add a history record of the license check with a checkStatus of false, indicating a failed check. It also includes a custom error message 'Something went wrong in processing this check!' and, if available, the response code from the error.
  3. Calls the updateDriverLicenceCheckStat function to update the driver's license check status to 'FAILED_LICENCE_CHECK'.
  4. Updates the requestingDriverLicenceCheck field in the database for the specified driver, setting it to false.
  5. Sends a JSON response to the client with an error message.

Status: Draft (Pending Review)
Category: Protected
Authored By: Sohan on Oct 05, 2023